<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    let str = `
        <ul>
            <li>
                <a href="#">肖申克的救赎</a>
                <p>上映时间: 1994-09-10</p>
            </li>
            <li>
                <a href="#">阿甘正传</a>
                <p>上映时间: 1994-07-06</p>
            </li>
        </ul>
    `
    // 没有dotAll模式
    const reg = /<a .*?>(.*?)<\/a>\s+<p>(.*?)<\/p>/g;
    let result = reg.exec(str);
    console.log(result);

    // dotAll模式
    const reg2 = /<a .*?>(.*?)<\/a>.*?<p>(.*?)<\/p>/gs;
    // 循环匹配多个
    let data = []
    while (result = reg2.exec(str)) {
        console.log(result);
        data.push({
            title: result[1],
            time: result[2]
        })
    }
    console.log(data);

    // matchAll
    const result3 = str.matchAll(reg2);
    for (const item of result3) {
        console.log(item);
    }




</script>

</html>